package com.example.ui;

import com.example.model.Goods;
import com.example.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Random;

/**
 * @ClassName: GoodsController
 * @Description:
 * @Author:
 * @Date
 */
@RestController
@RequestMapping(path = "/goods")
public class GoodsController {


    @Autowired
    GoodsService goodsService;

    @PostMapping(value = "addGoods.do")
    public void addGoods(@RequestParam(value = "goodPrice") Float goodPrice,
                         @RequestParam(value = "goodsName") String goodsName,
                         @RequestParam(value = "goodsNumber") int goodsNumber,
                         @RequestParam(value = "goodesDesc") String goodsDesc) {
        Goods goods = new Goods();
        goods.setGoodsName(goodsName);
        goods.setGoodsPrice(goodPrice);
        goods.setGoodsNumber(goodsNumber);
        goods.setGoodsDesc(goodsDesc);
        goods.setCreateTime(new Date());
        goodsService.addGoods(goods);
    }
}
